﻿using AutoMapper;
using MediatR;
using S.Authorization.API.Application.Command.Role;
using S.Authorization.Infrastructure.Interface.Role;

namespace S.Authorization.API.Application.CommandHandlers.Role
{
    /// <summary>
    /// 角色表删除
    /// </summary>
    public class RoleDeleteCommandHandler : IRequestHandler<RoleDeleteCommand, bool>
    {
        #region 注入
        private readonly IRoleRepository repository;

        public RoleDeleteCommandHandler(IRoleRepository repository)
        {
            this.repository = repository;
        }
        #endregion
        public async Task<bool> Handle(RoleDeleteCommand request, CancellationToken cancellationToken)
        {
            return await repository.DeleteAsync(request.RoleId);
        }
    }
}
